@import be.objectify.deadbolt.scala.AuthenticatedRequest
@(handler: be.objectify.deadbolt.scala.DeadboltHandler)(implicit request: AuthenticatedRequest[Any])

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/html" lang="en">
<head>
    <title>Deadbolt 2 Scala examples</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" media="screen" href='@routes.Assets.at("stylesheets/main.css")'>
    <link rel="stylesheet" media="screen" href='@routes.Assets.at("stylesheets/bootstrap.min.css")'>
    <link rel="stylesheet" media="screen" href='@routes.Assets.at("stylesheets/bootstrap-responsive.min.css")'>
    <link rel="stylesheet" media="screen" href='@routes.Assets.at("stylesheets/font-awesome.css")'>
    <link rel="shortcut icon" type="image/png" href='@routes.Assets.at("images/favicon.png")'>
</head>
<body>

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container-fluid">
            <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <a class="brand" href="#">Deadbolt 2 Scala examples</a>
            <div class="nav-collapse collapse">
                <ul class="nav">
                    <li><a href="http://www.objectify.be" target="_blank"><i class="icon-globe"></i>Objectify</a></li>
                    <li><a href="https://twitter.com/steve_objectify" target="_blank"><i class="icon-twitter"></i> Twitter</a></li>
                    <li><a href="https://www.github.com/schaloner" target="_blank"><i class="icon-github"></i> GitHub</a></li>
                    <li><a href="http://deadbolt-2-java.herokuapp.com" target="_blank"><i class="icon-beaker"></i> Deadbolt 2 Java examples</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2">
            <div class="well sidebar-nav">
                <ul class="nav nav-list">
                    <li class="nav-header">General</li>
                    <li><a href="#config">Configuration</a></li>
                    <li class="nav-header">Controllers</li>
                    <li><a href="#controller-SubjectPresent">SubjectPresent</a></li>
                    <li><a href="#controller-SubjectNotPresent">SubjectNotPresent</a></li>
                    <li><a href="#controller-Restrict">Restrictions - shorthand version</a></li>
                    <li><a href="#controller-Dynamic">Dynamic</a></li>
                    <li><a href="#controller-Pattern">Pattern</a></li>
                    <li class="nav-header">Templates</li>
                    <li><a href="#template-subjectPresent">@@subjectPresent</a></li>
                    <li><a href="#template-subjectNotPresent">@@subjectNotPresent</a></li>
                    <li><a href="#template-restrict">@@restrict</a></li>
                    <li><a href="#template-dynamic">@@dynamic</a></li>
                    <li><a href="#template-pattern">@@pattern</a></li>
                </ul>
            </div>
        </div>
        <div class="span10">
            <div class="hero-unit">
                <h1>Deadbolt 2 Scala</h1>

                <p>This is a collection of examples using Deadbolt 2 at both the controller and template level to
                    implement authorisation in a Play 2 application.</p>
            </div>
            <div class="row-fluid" id="config">
                <div class="span10">
                    <h2>Configuration</h2>

                    <p>For the purposes of these examples, except where stated otherwise, the user has the following roles:</p>
                    @defining(utils.TemplateUtils.getSubjectNow(handler, request).get) { subject =>
                    <ul>
                    @for(role <- subject.roles){
                        <li>@role.name</li>
                    }
                    </ul>

                    <p>The user also has the following permissions:</p>
                    <ul>
                    @for(permission <- subject.permissions){
                        <li>@permission.value</li>
                    }
                    </ul>
                    }
                </div>
            </div>
            <div class="row-fluid">
                <div class="span10">
                    <h2>Controller authorisation</h2>

                    <p>Protecting your controllers against unauthorised use is a key element of good application security.  Here, you'll find examples of each of the
                        controller-level authorisations provided by Deadbolt 2.</p>
                    <p>For each example, the action is shown on the left, and the result is loaded into an iframe on the right.</p>
                </div>
            </div>

            @examples.controllers.SubjectPresent()
            @examples.controllers.SubjectNotPresent()
            @examples.controllers.Restrict()
            @examples.controllers.Dynamic()
            @examples.controllers.Pattern()

            <div class="row-fluid">
                <div class="span10">
                    <h2>Template authorisation</h2>

                    <p>Deadbolt tags does not offer any real protected against misuse on your server side, but it does allow you to customise your UI according to the
                       privileges of the current user.</p>
                    <p>Each tag has an "Or" variant, e.g. restrictOr, that allows you to pass in a alternative body for when authorisation fails.</p>
                    <p>For each example, the unprotected content is on the left, the Deadbolt tag is in the center and the result of the authorisation is on the right.</p>
                </div>
            </div>

            @examples.templates.SubjectPresent(handler)
            @examples.templates.SubjectNotPresent(handler)
            @examples.templates.Restrict
            @examples.templates.Dynamic(handler)
            @examples.templates.Pattern(handler)

        </div>
    </div>

    <hr>

    <footer>
        <p>&copy; Steve Chaloner &amp; Objectify 2010 - 2015</p>
    </footer>

</div>
<!--/.fluid-container-->
<script src='@routes.Assets.at("javascripts/jquery-1.7.1.min.js")' type="text/javascript"></script>
<script src='@routes.Assets.at("javascripts/bootstrap.min.js")' type="text/javascript"></script>
</body>
</html>